import React, { forwardRef, useImperativeHandle, useState } from 'react';

export default forwardRef((props: any, ref: any) => {
  const { onChange } = props;
  const [value, setValue] = useState(0);

  const onClick = () => {
    setValue(value + 1);
    onChange(value + 1);
  };
  useImperativeHandle(ref, () => ({
    getValue: () => {
      return false;
    },
  }));
  return <span onClick={onClick}>{value}</span>;
});
